<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>pthread_exit</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_007_1342">&nbsp;</a>NAME</h4><blockquote>
pthread_exit - thread termination
</blockquote><h4><a name = "tag_000_007_1343">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="pthread.h.html">pthread.h</a>&gt;

void pthread_exit(void *<i>value_ptr</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_007_1344">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>pthread_exit()</i>
function terminates the calling thread and makes the value
<i>value_ptr</i>
available to any successful join with the terminating thread.
Any cancellation cleanup handlers
that have been pushed and not yet popped are popped in the reverse order
that they were pushed and then executed.
After all cancellation cleanup handlers have been executed,
if the thread has any thread-specific data,
appropriate destructor functions will be called in an unspecified order.
Thread termination does not release any application visible process resources,
including, but not limited to, mutexes and file descriptors,
nor does it perform any process level cleanup actions,
including, but not limited to, calling any
<i><a href="atexit.html">atexit()</a></i>
routines that may exist.
<p>
An implicit call to
<i>pthread_exit()</i>
is made when a thread other than the thread in which
<i>main()</i>
was first invoked returns from the start routine
that was used to create it.
The function's return value serves as the thread's exit status.
<p>
The behaviour of
<i>pthread_exit()</i>
is undefined if called from a
cancellation cleanup handler
or destructor function
that was invoked as a result of either an implicit or
explicit call to
<i>pthread_exit()</i>.
<p>
After a thread has terminated,
the result of access to local (auto) variables of the thread is undefined.
Thus, references to local variables of the exiting thread
should not be used for the
<i>pthread_exit()</i>
<i>value_ptr</i>
parameter value.
<p>
The process exits with an exit status of 0 after the
last thread has been terminated.
The behaviour is as if the implementation called
<i><a href="exit.html">exit()</a></i>
with a zero argument at thread termination time.
</blockquote><h4><a name = "tag_000_007_1345">&nbsp;</a>RETURN VALUE</h4><blockquote>
The
<i>pthread_exit()</i>
function cannot return to its caller.
</blockquote><h4><a name = "tag_000_007_1346">&nbsp;</a>ERRORS</h4><blockquote>
No errors are defined. 
<p>
The
<i>pthread_exit()</i>
function will not return an error code of [EINTR].
</blockquote><h4><a name = "tag_000_007_1347">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_1348">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_1349">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_1350">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="pthread_create.html">pthread_create()</a></i>,
<i><a href="pthread_join.html">pthread_join()</a></i>,
<i><a href="exit.html">exit()</a></i>,
<i><a href="_exit.html">_exit()</a></i>,
<i><a href="pthread.h.html">&lt;pthread.h&gt;</a></i>.
</blockquote><h4>DERIVATION</h4><blockquote>
Derived from the POSIX Threads Extension (1003.1c-1995)
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>

